Skip to content

test: pin FitEllipse masked-points-loop behaviour#395

Merged
Jammy2211 merged 1 commit into
mainfrom
feature/ellipse-fit-masked-loop-tests
May 10, 2026
Merged

test: pin FitEllipse masked-points-loop behaviour#395
Jammy2211 merged 1 commit into
mainfrom
feature/ellipse-fit-masked-loop-tests

Conversation

@Jammy2211
Copy link
Copy Markdown
Collaborator

Summary

Pin the current behaviour of FitEllipse.points_from_major_axis_from's 300-iteration mask-rejection loop with five new unit tests in test_autogalaxy/ellipse/test_fit_ellipse.py. Step 3 of 7 in the ellipse_fitting_jax feature decomposition — prompt 6 will rewrite this loop with a JAX-friendly oversample-then-NaN-mask approach; these tests are the regression target it must reproduce.

Each test pins one of the four loop branches plus a multipole variant. Where the loop converges deterministically (zero-masked, under-masked-trim, multipole), the full (N, 2) returned array is pinned at rtol=1e-12. Where the iteration count varies more (over-masked-extra-points), the first and last point are spot-checked at the same tolerance.

Test Loop branches exercised
zero_masked equals-branch every iteration (mask is far from ellipse perimeter)
under_masked_trim extra-points (i=1) → trim (i=2) → equals (i≥3); one perimeter point is masked
over_masked_extra_points extra-points (i=1, 2) → equals (i≥3); 3×3 mask block straddles perimeter
unreachable_raises extra-points fires every iteration to i=300, then raises ValueError
with_multipole_under_masked same path as under_masked_trim with EllipseMultipole(m=4) — pins the inner multipole branch at lines 113-120

All tests numpy-only per PyAutoGalaxy/CLAUDE.md's "Never use JAX in unit tests" rule. JAX parity will be checked in the workspace_test scripts shipped in prompt 2 once prompt 7 lands.

Issue #394.

API Changes

None — test additions only.

Test Plan

  • python -m pytest test_autogalaxy/ellipse/test_fit_ellipse.py -v passes (16/16: 11 pre-existing + 5 new)
  • Full python -m pytest test_autogalaxy/ passes
  • Reference values byte-stable across runs (scipy RegularGridInterpolator is deterministic)

🤖 Generated with Claude Code

Add 5 unit tests + a 30x30 imaging fixture to test_autogalaxy/ellipse/
test_fit_ellipse.py that cover every branch of the 300-iteration
mask-rejection loop in autogalaxy/ellipse/fit_ellipse.py:69-136:
zero-masked, under-masked (trim), over-masked (extra-points),
unreachable (ValueError), and the multipole inner branch. Pinned
to rtol=1e-12 reference arrays where the path is deterministic;
spot-checks where the iteration count varies. Numpy-only.

Step 3 of 7 in z_features/ellipse_fitting_jax.md. Prompt 6 will
rewrite this loop with JAX-friendly oversample-then-NaN-mask; these
tests are the regression target it must reproduce.

Issue #394.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@Jammy2211 Jammy2211 added the pending-release PR queued for the next release build label May 10, 2026
@Jammy2211 Jammy2211 merged commit 0523ea9 into main May 10, 2026
5 checks passed
@Jammy2211 Jammy2211 deleted the feature/ellipse-fit-masked-loop-tests branch May 10, 2026 20:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pending-release PR queued for the next release build

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant